#include "whaleplugin.h"

#include <QtDebug>

WhalePlugin::WhalePlugin( QObject * pluginObject, bool enabled ) {
    this->PluginObject = pluginObject;
    this->Enabled = enabled;
    TabInterface * iTab = qobject_cast< TabInterface * >( this->PluginObject );
    if ( iTab ) {
        this->Type = TabPlugin;
        this->Name = iTab->name();
        return;
    }

    // else
    this->Type = Unknown;
}

TabInterface * WhalePlugin::getTabInterface() {
    if ( this->Type != TabPlugin ) {
        return NULL;
    }
    return qobject_cast< TabInterface * >( this->PluginObject );
}

void WhalePlugin::setEnabled( int value ) {
    this->Enabled = value;
    if ( value ) {
        emit enabled();
    }
    else {
        emit disabled();
    }
    emit stateChanged( value ); // for those who prefer it this way
}
